package com.liveinstars.quhui.business.interest.service.impl;

import com.baidu.unbiz.easymapper.MapperFactory;
import com.liveinstars.api.dto.InterestDetailDto;
import com.liveinstars.api.dto.InterestDto;
import com.liveinstars.api.dto.InterestSimpleDto;
import com.liveinstars.quhui.business.interest.repository.po.InterestGroup;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 进行po和实体的转换，和event的生成等工作
 */
@Service
public class InterestFactory {
    public List<InterestSimpleDto> getSimpleInterestDtos(List<InterestGroup> list) {

        MapperFactory.getCopyByRefMapper().mapClass(InterestGroup.class, InterestSimpleDto.class).register();
        List<InterestSimpleDto> interestDtoS = list.stream().map(p -> MapperFactory.getCopyByRefMapper().map(p,
                InterestSimpleDto.class)).collect(Collectors.toList());
        return interestDtoS;
    }

    public List<InterestDto> getInterestDtos(List<InterestGroup> list) {

        MapperFactory.getCopyByRefMapper().mapClass(InterestGroup.class, InterestSimpleDto.class).register();
        List<InterestDto> interestDtoS = list.stream().map(p -> MapperFactory.getCopyByRefMapper().map(p,
                InterestDto.class)).collect(Collectors.toList());
        return interestDtoS;
    }

    public InterestDetailDto getInterestDto(InterestGroup interestGroup) {
        InterestDetailDto interestDetailDto = MapperFactory.getCopyByRefMapper().mapClass(InterestGroup.class, InterestDetailDto.class).register()
                .map(interestGroup, InterestDetailDto.class);
        return interestDetailDto;
    }
//    public ActivityDO getActivityDO(Activity activity) {
//
//        ActivityDO activityVO = MapperFactory.getCopyByRefMapper().mapClass(Activity.class, ActivityDO.class).register()
//                .map(activity, ActivityDO.class);
//        return activityVO;
//    }
//
//    public Activity createActivityPO(ActivityDO vo) {
//        Activity activity = MapperFactory.getCopyByRefMapper().mapClass(ActivityDO.class, Activity.class).register()
//                .map(vo, Activity.class);
//        return activity;
//    }
//
//    public List<ActivityDO> getActivityDOs(List<Activity> records) {
//
//        MapperFactory.getCopyByRefMapper().mapClass(Activity.class, ActivityDO.class).register();
//        List<ActivityDO> activityDOS = records.stream().map(p -> MapperFactory.getCopyByRefMapper().map(p,
//                ActivityDO.class)).collect(Collectors.toList());
//        return activityDOS;
//    }
}
